package org.keyroy.map_editor.map;

import java.util.ArrayList;
import java.util.List;

import org.keyory.map_editor.model.Drawable;
import org.keyroy.map_editor.map.action.MapAction;
import org.keyroy.map_editor.map.m.Rect;
import org.keyroy.tag.Tag;

public abstract class MapSprite extends Rect implements Drawable {
	private List<MapAction> actions;
	public MapZone mapZone;
	public Map map;
	public String source;
	public String name;

	public void addAction(MapAction mapAction) {
		if (actions == null) {
			actions = new ArrayList<MapAction>(1);
		}
		actions.add(mapAction);
	}

	@Override
	public void initObj(Tag tag) {
		super.initObj(tag);
		name = tag.getParameterValue("name");
		source = tag.getParameterValue("source");
		tag.getChildObjectArray(MapAction.class, actions);

	}

	@Override
	public void initTag(Tag tag) {
		super.initTag(tag);
		tag.addParameter("name", name);
		tag.addParameter("source", source);
		tag.addChild(actions);
	}

	@Override
	public String getTagName() {
		return "s";
	}
}
